package by.bsuir.sn.util
{
	import flash.utils.describeType;
	import flash.utils.getDefinitionByName;
	import flash.utils.getQualifiedClassName;

	public class ObjUtil
	{
		public static function getName(o : *) : String
		{
			return getQualifiedClassName(o).split("::").pop();
		}

		public static function getClass(o : *) : Class
		{
			return getDefinitionByName(getQualifiedClassName(o)) as Class;
		}

		public static function getProperties(o : *) : Array
		{
			var description : XML = describeType(o);
			var xList : XMLList = description..accessor;
			var keys : Array = new Array();
			for each(var node : XML in xList)
			{
				keys.push(String(node.@name));
			}
			return keys;
		}

		public static function getPopertyType(o : *, prop : String) : String
		{
			var description : XML = describeType(o);
			return String(description..accessor.(@name == prop).@type[0]);
		}
	}
}